//
//  XunJianViewController.m
//  Qihuo
//
//  Created by ~Fighting~ on 13-10-20.
//  Copyright (c) 2013年 Vencoo. All rights reserved.
//
#import "AppDelegate.h"
#import "PickerBackgroundView.h"
#import "XunJianViewController.h"
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>
@interface XunJianViewController (){
//    NSMutableArray *inputTextFields;
    NSMutableArray *iconImageViews;
//    NSMutableArray *inputTfText;
    NSMutableArray *selectLbText;
    NSMutableArray *sendControls;
    NSMutableArray *funtionDatas;
    NSMutableArray *photos;
    NSMutableArray *functionCheckDataArr;
    NSMutableArray *Aphoto;
    NSMutableArray *sendFunctionChilds;
    NSMutableArray *cannotEditTfs;
    NSArray *valueArr;
    NSArray *classTableFactors;
    NSMutableArray *myFloorArr;
    int btnCount;
    ASIFormDataRequest *loginRequest;
    ASIFormDataRequest *sendRequest;
    PickerBackgroundView *pickerView;

    UIImage *btnImage1;
    UIImage *btnImage2;
    UIImage *inputImage;
    UIButton *takePhotoBtn;
   
    UIImageView *showImageV;
    UITextField *dealTimeTf;
    UITextView *contentTv;
    UITextView *remarkTv;
    UITableView *classTable;
    UITableView *buWeiTable;
    UIImageView *myAlertView;
    NSString *isAbolished;
}

@end

@implementation XunJianViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {

    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initialize];
    _checkArea = @"";
    _hostStr = @"";
    _softwareStr = @"";
    _communicationStr = @"";
    UIImage *blackImage = [UIImage imageNamed:@"黑底"];
    _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(interval111/2, 64, _leftTableImage.size.width, screenHeight - blackImage.size.height - 64) style:UITableViewStylePlain];
    UIImageView *tableBackView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"xunjiantableViewDi.jpg"]];
    [_myTableView setBackgroundView:tableBackView];
    _myTableView.dataSource = self;
    _myTableView.delegate = self;
    [self.view addSubview:_myTableView];
    
    self.blackView = [[UIImageView alloc]initWithImage:blackImage];
    self.blackView.backgroundColor = [UIColor clearColor];
    self.blackView.frame = CGRectMake(_myTableView.frame.origin.x - 1.5, screenHeight - blackImage.size.height, blackImage.size.width, blackImage.size.height);
    self.blackView.userInteractionEnabled = YES;
    [self.view addSubview:self.blackView];
    self.blackView.tag = 4444;
    UIImage *repairImage = [UIImage imageNamed:@"报修"];
    UIImage *saveImage = [UIImage imageNamed:@"保存"];
    UIImage *abortionImage = [UIImage imageNamed:@"中途结束巡检"];
    NSArray *imageArrar = @[saveImage,repairImage,abortionImage];
    for (int i = 0 ; i < 3; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setImage:[imageArrar objectAtIndex:i] forState:UIControlStateNormal];
        [btn setFrame:CGRectMake((blackImage.size.width - saveImage.size.width - repairImage.size.width - abortionImage.size.width)/4*(i+1) + (saveImage.size.width)*i, (blackImage.size.height - abortionImage.size.height)/2, ((UIImage*)[imageArrar objectAtIndex:i]).size.width, abortionImage.size.height)];
        btn.tag = i;
        
        [btn addTarget:self action:@selector(jajajajaj:) forControlEvents:UIControlEventTouchUpInside];
        [self.blackView addSubview:btn];
    }
    UIImage *whiteImage = [UIImage imageNamed:@"小白白白底"];
    _whiteImageView = [[UIImageView alloc]initWithFrame:CGRectMake(_myTableView.frame.origin.x + _myTableView.frame.size.width, _myTableView.frame.origin.y, scrennWidth - (_myTableView.frame.origin.x)*2 -_myTableView.frame.size.width, _myTableView.frame.size.height)];
    _whiteImageView.image = whiteImage;
    _whiteImageView.userInteractionEnabled = YES;
    [self.view addSubview:_whiteImageView];
    
    _backScrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 10, _whiteImageView.frame.size.width - 20, _whiteImageView.frame.size.height - 20)];
    _backScrollV.delegate = self;
    [_whiteImageView addSubview:_backScrollV];
    [self addBaoXiuView];
    [self addDatePickerView];
    [self addStopXunJian];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenKeyboard)];
    [self.backScrollV addGestureRecognizer:tap];

    
    myAlertView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"黑底1"]];
    myAlertView.center = CGPointMake(0, 0);
    UILabel *alertLb = [UILabel new];
    alertLb.text = @"签到成功！！！";
    alertLb.font = [UIFont systemFontOfSize:100];
    CGSize textSz = [alertLb.text sizeWithFont:alertLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    alertLb.backgroundColor = [UIColor clearColor];
    alertLb.textColor = [UIColor whiteColor];
    alertLb.frame = CGRectMake((scrennWidth - textSz.width)/2, (screenHeight - textSz.height)/2, textSz.width, textSz.height);
    [myAlertView addSubview:alertLb];
    [self.view addSubview:myAlertView];
    myAlertView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHidden:)];
    [myAlertView addGestureRecognizer:tapGesture];
    myAlertView.hidden = YES;
    self.backScrollV.showsVerticalScrollIndicator = 0;
}
- (void)initialize
{
    isAbolished = @"0";
    myFloorArr = [NSMutableArray array];
    _controlWillClears = [NSMutableArray array];
    _sendAllDic = [NSMutableDictionary dictionary];
    _checkNameLbs = [NSMutableArray array];
    _imageViews = [NSMutableArray array];
    _tables = [NSMutableArray array];
    _childLabels = [NSMutableArray array];
    _tableFactors = [NSMutableArray array];
    _tableValues = [NSMutableArray array];
    _tableLabels = [NSMutableArray array];
    _tableTextViews = [NSMutableArray array];
    _tableBtns = [NSMutableArray array];
    _selectBtnArr = [NSMutableArray array];
//    inputTextFields = [NSMutableArray array];
//    inputTfText = [NSMutableArray array];
//    _inputTvText = [NSMutableArray array];
    selectLbText = [NSMutableArray array];
    photos = [NSMutableArray array];
    _floorNames = [NSMutableArray array];
    cannotEditTfs = [NSMutableArray array];
    _abnormals = @[@"无异常",@"异常"];
    classTableFactors = @[@"外部报修",@"内部报修"];
    _floorIds = [NSMutableArray array];
    iconImageViews = [NSMutableArray array];
    sendControls = [NSMutableArray array];
    _sendFloorDatas = [NSMutableArray array];
//    _functiontext = [NSMutableArray array];
    funtionDatas = [NSMutableArray array];
    _xunJianCellInfos = [NSMutableArray array];
    functionCheckDataArr = [NSMutableArray array];
    sendFunctionChilds = [NSMutableArray array];
    _seleBtnData = [NSMutableArray array];
    showImageV = [[UIImageView alloc]initWithFrame:CGRectZero];
    showImageV.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenImageView:)];
    [showImageV addGestureRecognizer:tap];
    
    inputImage = [UIImage imageNamed:@"输入框底"];
    btnImage1 = [UIImage imageNamed:@"下拉-按钮1"];
    btnImage2 = [UIImage imageNamed:@"下拉-按钮2"];
    _leftTableImage = [UIImage imageNamed:@"常态"];
    _roundSelect = [UIImage imageNamed:@"选中"];
    _roundUnselect = [UIImage imageNamed:@"未选中"];
    if (self.secureDelegate.openFrid || self.projectDelegate.openFrid || self.functionDelegate.openFrid)
    {
        self.fridUtil =[[FridUtil alloc]init];
        self.fridUtil.delegate = self;
        [self.fridUtil readData];
    }
//    [Appinfomation shareIstance].bBeep = YES;
// =====================必要的初始化=============
    _alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请确认您的用户身份"  delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [_alertV setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasHidden:) name:UIKeyboardWillHideNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(doSomething:) name:@"frid" object:nil];
}
- (void)addBaoXiuView
{
    UIImage *tfImage = [UIImage imageNamed:@"报修单底框"];
    UIImage *contentImage = [UIImage imageNamed:@"保修内容框"];
    UIImage *timeTfImage = [UIImage imageNamed:@"时间底框"];
    UIImage *calenderImage = [UIImage imageNamed:@"报修单日历按钮"];
    UIImage *picImage = [UIImage imageNamed:@"图片框"];
    UIImage *redioImage = [UIImage imageNamed:@"录音2"];
    UIImage *submitImage = [UIImage imageNamed:@"提交"];
//    UIImage *tableImage = [UIImage imageNamed:@"灰底下拉框"];

    self.blackGroundV = [[BlackbackgroundView alloc]initWithFrame:CGRectMake(0, 0, 1024, 768)];
    self.blackGroundV.userInteractionEnabled = YES;
    self.blackGroundV.delegate = self;
    [self.view addSubview:self.blackGroundV];
    
    UILabel *titleLb = [UILabel new];
    titleLb.text = @"报修单";
    titleLb.font = [UIFont systemFontOfSize:35];
    titleLb.backgroundColor = [UIColor clearColor];
    CGSize sz = [titleLb.text sizeWithFont:titleLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    titleLb.frame = CGRectMake((self.blackGroundV.frame.size.width - sz.width)/2, 80, sz.width, sz.height);
    [self.blackGroundV addSubview:titleLb];
    
    UILabel *departmentLb = [UILabel new];
    departmentLb.text = @"报修部门：";
    departmentLb.font = [UIFont systemFontOfSize:25];
    departmentLb.backgroundColor = [UIColor clearColor];
    sz = [departmentLb.text sizeWithFont:departmentLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    departmentLb.frame = CGRectMake(110, titleLb.frame.origin.y + titleLb.frame.size.height + interval111, sz.width, sz.height);
    [self.blackGroundV addSubview:departmentLb];
    
    UITextField *departmentTf = [[UITextField alloc]initWithFrame:CGRectMake(departmentLb.frame.size.width + departmentLb.frame.origin.x, departmentLb.frame.origin.y, tfImage.size.width, sz.height)];
    [departmentTf setFont:[UIFont systemFontOfSize:23]];
    departmentTf.enabled = NO;
    switch ([[[Appinfomation shareIstance].loginDic valueForKey:@"departmentid"]integerValue]) {
        case 1:
        {
            departmentTf.text = @"保安部";
        }
            break;
        case 2:
        {
            departmentTf.text = @"工程部";
        }
            break;
        case 3:
        {
            departmentTf.text = @"运作部";
        }
            break;
            
        default:
            break;
    }
    [departmentTf setBackground:tfImage];
    [self.blackGroundV addSubview:departmentTf];
    
    UILabel *personLb = [UILabel new];
    personLb.text = @"报修人：";
    personLb.font = [UIFont systemFontOfSize:25];
    personLb.backgroundColor = [UIColor clearColor];
    sz = [personLb.text sizeWithFont:personLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    personLb.frame = CGRectMake(departmentTf.frame.size.width + departmentTf.frame.origin.x + interval111, departmentLb.frame.origin.y, sz.width, sz.height);
    [self.blackGroundV addSubview:personLb];
    
    UITextField *personTf = [[UITextField alloc]initWithFrame:CGRectMake(personLb.frame.size.width + personLb.frame.origin.x + 25, departmentLb.frame.origin.y, departmentTf.frame.size.width, sz.height)];
    personTf.text = [[Appinfomation shareIstance].loginDic objectForKey:@"username"];
    [personTf setFont:[UIFont systemFontOfSize:23]];
    [personTf setBackground:tfImage];
    [self.blackGroundV addSubview:personTf];
    
    UILabel *teleLb = [UILabel new];
    teleLb.text = @"联系电话：";
    teleLb.font = [UIFont systemFontOfSize:25];
    teleLb.backgroundColor = [UIColor clearColor];
    sz = [teleLb.text sizeWithFont:teleLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    teleLb.frame = CGRectMake(departmentLb.frame.origin.x, departmentLb.frame.origin.y + departmentLb.frame.size.height + interval111, sz.width, sz.height);
    [self.blackGroundV addSubview:teleLb];
    
    UITextField *teleTf = [[UITextField alloc]initWithFrame:CGRectMake(departmentTf.frame.origin.x, teleLb.frame.origin.y, departmentTf.frame.size.width, sz.height)];
    [teleTf setFont:[UIFont systemFontOfSize:23]];
    [teleTf setBackground:tfImage];
    [self.blackGroundV addSubview:teleTf];
    
    UILabel *dealTimeLb = [UILabel new];
    dealTimeLb.text = @"受理时间：";
    dealTimeLb.font = [UIFont systemFontOfSize:25];
    dealTimeLb.backgroundColor = [UIColor clearColor];
    sz = [dealTimeLb.text sizeWithFont:dealTimeLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    dealTimeLb.frame = CGRectMake(personLb.frame.origin.x, teleLb.frame.origin.y, sz.width, sz.height);
    [self.blackGroundV addSubview:dealTimeLb];
    
    NSDateFormatter *dateForm = [NSDateFormatter new];
    [dateForm setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *fromDateString = [dateForm stringFromDate:[NSDate date]];
    
    dealTimeTf = [[UITextField alloc]initWithFrame:CGRectMake(personTf.frame.origin.x, dealTimeLb.frame.origin.y, timeTfImage.size.width, sz.height)];
    [dealTimeTf setFont:[UIFont systemFontOfSize:23]];
    dealTimeTf.enabled = NO;
    dealTimeTf.text = fromDateString;
    [dealTimeTf setBackground:timeTfImage];
    [self.blackGroundV addSubview:dealTimeTf];
    
    UIButton *dateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [dateBtn setImage:calenderImage forState:UIControlStateNormal];
    [dateBtn addTarget:self action:@selector(selectTime:) forControlEvents:UIControlEventTouchUpInside];
    dateBtn.frame = CGRectMake(dealTimeTf.frame.origin.x + dealTimeTf.frame.size.width + interval111, dealTimeTf.frame.origin.y - (calenderImage.size.height - sz.height)/2, calenderImage.size.width, calenderImage.size.height);
    [self.blackGroundV addSubview:dateBtn];
    
    UILabel *classLb = [UILabel new];
    classLb.text = @"报事类别：";
    classLb.font = [UIFont systemFontOfSize:25];
    classLb.backgroundColor = [UIColor clearColor];
    sz = [classLb.text sizeWithFont:classLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    classLb.frame = CGRectMake(teleLb.frame.origin.x, teleLb.frame.origin.y + teleLb.frame.size.height + interval111, sz.width, sz.height);
    [self.blackGroundV addSubview:classLb];
    
    UITextField *classTf = [[UITextField alloc]initWithFrame:CGRectMake(teleTf.frame.origin.x, classLb.frame.origin.y, teleTf.frame.size.width, sz.height)];
    [classTf setFont:[UIFont systemFontOfSize:23]];
    [classTf setBackground:tfImage];
    classTf.delegate = self;
    [self.blackGroundV addSubview:classTf];
    [cannotEditTfs addObject:classTf];
    
    UIButton *seleBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [seleBtn1 setImage:btnImage1 forState:UIControlStateNormal];
    seleBtn1.tag = 101;
    [seleBtn1 addTarget:self action:@selector(openTable:) forControlEvents:UIControlEventTouchUpInside];
    seleBtn1.frame = CGRectMake(tfImage.size.width - btnImage1.size.width, 0, btnImage1.size.width, btnImage1.size.height);
    [classTf addSubview:seleBtn1];
    
    UILabel *buWeiLb = [UILabel new];
    buWeiLb.text = @"报修部位：";
    buWeiLb.font = [UIFont systemFontOfSize:25];
    buWeiLb.backgroundColor = [UIColor clearColor];
    sz = [buWeiLb.text sizeWithFont:buWeiLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    buWeiLb.frame = CGRectMake(dealTimeLb.frame.origin.x, classLb.frame.origin.y, sz.width, sz.height);
    [self.blackGroundV addSubview:buWeiLb];
    
    UITextField *buWeiTf = [[UITextField alloc]initWithFrame:CGRectMake(dealTimeTf.frame.origin.x, classLb.frame.origin.y, teleTf.frame.size.width, sz.height)];
    [buWeiTf setFont:[UIFont systemFontOfSize:23]];
    [buWeiTf setBackground:tfImage];
    buWeiTf.delegate = self;
    [self.blackGroundV addSubview:buWeiTf];
    [cannotEditTfs addObject:buWeiTf];
    
    UIButton *seleBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [seleBtn2 setImage:btnImage1 forState:UIControlStateNormal];
    seleBtn2.tag = 102;
    seleBtn2.frame = CGRectMake(tfImage.size.width - btnImage1.size.width, 0, btnImage1.size.width, btnImage1.size.height);
    [seleBtn2 addTarget:self action:@selector(openTable:) forControlEvents:UIControlEventTouchUpInside];
    [buWeiTf addSubview:seleBtn2];

    UILabel *dealPerson = [UILabel new];
    dealPerson.text = @"受理人：";
    dealPerson.font = [UIFont systemFontOfSize:25];
    dealPerson.backgroundColor = [UIColor clearColor];
    sz = [dealPerson.text sizeWithFont:dealPerson.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    dealPerson.frame = CGRectMake(classLb.frame.origin.x, classLb.frame.origin.y + classLb.frame.size.height + interval111, sz.width, sz.height);
    [self.blackGroundV addSubview:dealPerson];
    
    UITextField *dealPersonTf = [[UITextField alloc]initWithFrame:CGRectMake(classTf.frame.origin.x, dealPerson.frame.origin.y, teleTf.frame.size.width, sz.height)];
    [dealPersonTf setFont:[UIFont systemFontOfSize:23]];
    dealPersonTf.enabled = NO;
    dealPersonTf.text = [[Appinfomation shareIstance].loginDic valueForKey:@"username"];
    [dealPersonTf setBackground:tfImage];
    [self.blackGroundV addSubview:dealPersonTf];
    
    UILabel *contentLb = [UILabel new];
    contentLb.text = @"报修内容：";
    contentLb.font = [UIFont systemFontOfSize:25];
    contentLb.backgroundColor = [UIColor clearColor];
    sz = [contentLb.text sizeWithFont:contentLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    contentLb.frame = CGRectMake(classLb.frame.origin.x, dealPerson.frame.origin.y + dealPerson.frame.size.height + interval111, sz.width, sz.height);
    [self.blackGroundV addSubview:contentLb];
    
    contentTv = [[UITextView alloc]initWithFrame:CGRectMake(dealPersonTf.frame.origin.x, contentLb.frame.origin.y, contentImage.size.width, contentImage.size.height)];
    [contentTv setBackgroundColor:[UIColor whiteColor]];
    [self.blackGroundV addSubview:contentTv];
    
    UILabel *takePhotoLb = [UILabel new];
    takePhotoLb.text = @"拍   照：";
    takePhotoLb.font = [UIFont systemFontOfSize:25];
    takePhotoLb.backgroundColor = [UIColor clearColor];
    sz = [takePhotoLb.text sizeWithFont:takePhotoLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    takePhotoLb.frame = CGRectMake(classLb.frame.origin.x, contentTv.frame.origin.y + contentTv.frame.size.height + interval111, sz.width, sz.height);
    [self.blackGroundV addSubview:takePhotoLb];

    takePhotoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [takePhotoBtn setImage:picImage forState:UIControlStateNormal];
    [takePhotoBtn addTarget:self action:@selector(openCamera:) forControlEvents:UIControlEventTouchUpInside];
    takePhotoBtn.frame = CGRectMake(contentTv.frame.origin.x, takePhotoLb.frame.origin.y, picImage.size.width, picImage.size.height);
    [self.blackGroundV addSubview:takePhotoBtn];
    
    UILabel *takeRadioLb = [UILabel new];
    takeRadioLb.text = @"录   音：";
    takeRadioLb.font = [UIFont systemFontOfSize:25];
    takeRadioLb.backgroundColor = [UIColor clearColor];
    sz = [takeRadioLb.text sizeWithFont:takeRadioLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    takeRadioLb.frame = CGRectMake(classLb.frame.origin.x, takePhotoBtn.frame.origin.y + takePhotoBtn.frame.size.height + interval111, sz.width, sz.height);
    [self.blackGroundV addSubview:takeRadioLb];
    
    UIButton *takeRadioBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [takeRadioBtn setImage:redioImage forState:UIControlStateNormal];
    takeRadioBtn.frame = CGRectMake(contentTv.frame.origin.x, takeRadioLb.frame.origin.y, redioImage.size.width, redioImage.size.height);
    [self.blackGroundV addSubview:takeRadioBtn];

    UIButton *submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [submitBtn setImage:submitImage forState:UIControlStateNormal];
    submitBtn.frame = CGRectMake((scrennWidth - submitImage.size.width)/2, takeRadioBtn.frame.origin.y + takeRadioBtn.frame.size.height + 5, submitImage.size.width, submitImage.size.height);
    [self.blackGroundV addSubview:submitBtn];
    
    classTable = [[UITableView alloc]initWithFrame:CGRectMake(classTf.frame.origin.x, classTf.frame.origin.y + classTf.frame.size.height, classTf.frame.size.width, 150) style:UITableViewStylePlain];
    classTable.dataSource = self;
    classTable.delegate = self;
    [self.blackGroundV addSubview:classTable];
    classTable.hidden = YES;
    
    buWeiTable = [[UITableView alloc]initWithFrame:CGRectMake(buWeiTf.frame.origin.x, buWeiTf.frame.origin.y + buWeiTf.frame.size.height, buWeiTf.frame.size.width, 150) style:UITableViewStylePlain];
    buWeiTable.dataSource = self;
    buWeiTable.delegate = self;
    [self.blackGroundV addSubview:buWeiTable];
    buWeiTable.hidden = YES;
    
    self.blackGroundV.hidden = YES;
}
- (void)addDatePickerView
{
    pickerView = [[PickerBackgroundView alloc]initWithFrame:CGRectMake(0, 0, scrennWidth, screenHeight)];
    [pickerView canDateAndTime];
    pickerView.butonDelegate = self;
    pickerView.userInteractionEnabled = YES;
    [self.view addSubview:pickerView];
    pickerView.hidden = YES;
}
- (void)addStopXunJian
{
    UIImage *tfImage = [UIImage imageNamed:@"报修单底框"];
    UIImage *submitImage = [UIImage imageNamed:@"提交"];

    self.blackStopV = [[BlackbackgroundView alloc]initWithFrame:CGRectMake(0, 0, scrennWidth, screenHeight)];
    self.blackStopV.userInteractionEnabled = YES;
    self.blackStopV.delegate = self;
    [self.view addSubview:self.blackStopV];
    
    UILabel *titleLb = [UILabel new];
    titleLb.text = @"取消巡检备注";
    titleLb.font = [UIFont systemFontOfSize:35];
    titleLb.backgroundColor = [UIColor clearColor];
    CGSize sz = [titleLb.text sizeWithFont:titleLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    titleLb.frame = CGRectMake((self.blackGroundV.frame.size.width - sz.width)/2, 80, sz.width, sz.height);
    [self.blackStopV addSubview:titleLb];
    
    UILabel *departmentLb = [UILabel new];
    departmentLb.text = @"巡检名称：";
    departmentLb.font = [UIFont systemFontOfSize:25];
    departmentLb.backgroundColor = [UIColor clearColor];
    sz = [departmentLb.text sizeWithFont:departmentLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    departmentLb.frame = CGRectMake(140, titleLb.frame.origin.y + titleLb.frame.size.height + interval111, sz.width, sz.height);
    [self.blackStopV addSubview:departmentLb];
    
    UITextField *departmentTf = [[UITextField alloc]initWithFrame:CGRectMake(departmentLb.frame.size.width + departmentLb.frame.origin.x, departmentLb.frame.origin.y, tfImage.size.width, sz.height)];
    [departmentTf setFont:[UIFont systemFontOfSize:23]];
    departmentTf.enabled = NO;
    departmentTf.text = self.title;
    [departmentTf setBackground:tfImage];
    [self.blackStopV addSubview:departmentTf];
    
    UILabel *personLb = [UILabel new];
    personLb.text = @"巡检时间：";
    personLb.font = [UIFont systemFontOfSize:25];
    personLb.backgroundColor = [UIColor clearColor];
    sz = [personLb.text sizeWithFont:personLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    personLb.frame = CGRectMake(departmentTf.frame.size.width + departmentTf.frame.origin.x + interval111*4, departmentLb.frame.origin.y, sz.width, sz.height);
    [self.blackStopV addSubview:personLb];
    
    UITextField *personTf = [[UITextField alloc]initWithFrame:CGRectMake(personLb.frame.size.width + personLb.frame.origin.x , departmentLb.frame.origin.y, departmentTf.frame.size.width, sz.height)];
    personTf.enabled = NO;
    NSDateFormatter *dateFormatter = [NSDateFormatter new];
    [dateFormatter setDateFormat:@"MM月dd日 HH：mm"];
    NSString *DateString = [dateFormatter stringFromDate:[NSDate date]];
    personTf.text = DateString;
    [personTf setFont:[UIFont systemFontOfSize:23]];
    [personTf setBackground:tfImage];
    [self.blackStopV addSubview:personTf];

    UILabel *contentLb = [UILabel new];
    contentLb.text = @"备 注：";
    contentLb.font = [UIFont systemFontOfSize:25];
    contentLb.backgroundColor = [UIColor clearColor];
    sz = [contentLb.text sizeWithFont:contentLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    contentLb.frame = CGRectMake(departmentLb.frame.origin.x, departmentLb.frame.origin.y + departmentLb.frame.size.height + interval111*2, sz.width, sz.height);
    [self.blackStopV addSubview:contentLb];
    
    remarkTv = [[UITextView alloc]initWithFrame:CGRectMake(contentLb.frame.origin.x + contentLb.frame.size.width, contentLb.frame.origin.y, 650, 200)];
    [remarkTv setBackgroundColor:[UIColor whiteColor]];
    [self.blackStopV addSubview:remarkTv];
    remarkTv.tag = 290;

    UIButton *submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [submitBtn setImage:submitImage forState:UIControlStateNormal];
    submitBtn.frame = CGRectMake((scrennWidth - submitImage.size.width)/2, remarkTv.frame.origin.y + remarkTv.frame.size.height + 5 + interval111 *2, submitImage.size.width, submitImage.size.height);
    [submitBtn addTarget:self action:@selector(abolishXunjian:) forControlEvents:UIControlEventTouchUpInside];
    [self.blackStopV addSubview:submitBtn];
    
    self.blackStopV.hidden = YES;

}
- (void)addRecorde
{
    isRecording = NO;
    
//    [self.playButton setEnabled:NO];
//     self.playButton.titleLabel.alpha = 0.5;
    recordedFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingString:@"RecordedFile"]];
    
    AVAudioSession *session = [AVAudioSession sharedInstance];
    
    NSError *sessionError;
    [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];
    
    if(session == nil)
        NSLog(@"Error creating session: %@", [sessionError description]);
    else
        [session setActive:YES error:nil];

}
-(void)viewWillAppear:(BOOL)animated
{
    [self.navigationItem setHidesBackButton:YES];
}
- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
}
- (void)clearAll//清空
{
    for (id control in _controlWillClears) {
        [control removeFromSuperview];
    }
    self.sendCheckDatas = [NSMutableArray array];
    [_controlWillClears removeAllObjects];
    for (UILabel *lable in _checkNameLbs) {
        [lable removeFromSuperview];
    }
    for (UIImageView *IV in _imageViews) {
        [IV removeFromSuperview];
    }
    for (UITableView *table in _tables) {
        [table removeFromSuperview];
    }
    for (UILabel *labek in _childLabels) {
        [labek removeFromSuperview];
    }
    for (NSArray *array in _selectBtnArr) {
        for (id contril in array) {
            [contril removeFromSuperview];
        }
    }
    for (id imageViews in iconImageViews) {
        [imageViews removeFromSuperview];
    }
    for (id some in photos) {
        [some removeFromSuperview];
    }
    [UIView animateWithDuration:0.7 animations:^{
        [_backScrollV setContentSize:CGSizeZero];
    }];
    takePhotoBtn.frame = CGRectMake(contentTv.frame.origin.x, contentTv.frame.origin.y + contentTv.frame.size.height + interval111, takePhotoBtn.frame.size.width, takePhotoBtn.frame.size.height);
    [photos removeAllObjects];
    [iconImageViews removeAllObjects];
    [_checkNameLbs removeAllObjects];
    [_imageViews removeAllObjects];
    [_tables removeAllObjects];
    [_childLabels removeAllObjects];
    [_tableLabels removeAllObjects];
    [_selectBtnArr removeAllObjects];
    [_seleBtnData removeAllObjects];
}

#pragma mark - button action
- (void)tapHidden:(id)sender
{
    [UIView animateWithDuration:.1 animations:^{
        myAlertView.frame = CGRectMake(scrennWidth/2, screenHeight/2, 0, 0);
    }];
    sleep(.5);
    myAlertView.hidden = YES;
}
- (void)selectOptions:(id)sender//工程部
{
    UIButton *btn = (UIButton*)sender;
    for (int i = 0;i<_selectBtnArr.count;i++)
    {
        NSArray *btnArr = [_selectBtnArr objectAtIndex:i];
        if ([btnArr containsObject:btn])
        {
            for (int j = 0;j<btnArr.count;j++)
            {
                UIButton *seleBtn = [btnArr objectAtIndex:j];
                [seleBtn setImage:self.roundUnselect forState:UIControlStateNormal];
                if (btn == [btnArr objectAtIndex:j])
                {
                    [seleBtn setImage:self.roundSelect forState:UIControlStateNormal];
                    [_seleBtnData replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%d",j]];
                }
            }
        }
        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%i",i+1],@"checkId",[_seleBtnData objectAtIndex:i],@"isNormal",nil];
        [_btnDatas replaceObjectAtIndex:i withObject:dic];
        //        NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:[checkId1s objectAtIndex:i],@"checkId",[_selectBtnArr objectAtIndex:i],@"isNormal",receiveArr,@"childData",nil];
        //        [inputTfText replaceObjectAtIndex:i withObject:dic1];
    }
    //    NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:floorIdQuanju,@"floorId",commentTv.text,@"remark",inputTfText,@"checkData", nil];
    //    [_inputTvText replaceObjectAtIndex:0 withObject:dic2];
}
- (void)selectBtns:(id)sender//运作部
{
    UIButton *btn = (UIButton*)sender;
    for (int i = 0;i<_selectBtnArr.count;i++)
    {
        NSArray *btnArr = [_selectBtnArr objectAtIndex:i];
        if ([btnArr containsObject:btn])
        {
            for (int j = 0;j<btnArr.count;j++)
            {
                UIButton *seleBtn = [btnArr objectAtIndex:j];
                [seleBtn setImage:_roundUnselect forState:UIControlStateNormal];
                if (btn == [btnArr objectAtIndex:j])
                {
                    [seleBtn setImage:_roundSelect forState:UIControlStateNormal];
//                    [_seleBtnData replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%d",j]];
                }
            }
        }
//        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[checkId1s objectAtIndex:i],@"checkId",[_seleBtnData objectAtIndex:i],@"checkResult",@"1",@"isNormal", nil];
//        [functionCheckDataArr replaceObjectAtIndex:i withObject:dic];
    }
 }
- (void)selectTime:(id)sender
{
    pickerView.hidden = NO;
}
- (void)openTable:(id)sender
{
    [[[UIApplication sharedApplication]keyWindow]endEditing:YES];
    UIButton *btn = (UIButton*)sender;
    if (btn.tag == 101)
    {
        if (classTable.hidden) {
            classTable.hidden = NO;
        }else{
            classTable.hidden = YES;
        }
    }
    else if (btn.tag == 102)
    {
        if (buWeiTable.hidden) {
            buWeiTable.hidden = NO;
        }else{
            buWeiTable.hidden = YES;
        }
    }
    else
    {
        UITableView *table = [self.tables objectAtIndex:btn.tag];
        if (table.hidden == YES)
        {
            [self hiddenAll];
            table.hidden = NO;
            [btn setImage:btnImage2 forState:UIControlStateNormal];
        }
        else
        {
            [self hiddenAll];
        }
    }
}
- (void)openCamera:(id)sender
{
    UIActionSheet *photoSheet = [[UIActionSheet alloc]initWithTitle:@"提示" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拍照" otherButtonTitles:@"从相册中选择" , nil];
    [photoSheet showInView:self.blackGroundV];
}
- (void)openRadio:(id)sender
{
    
}
- (void)displayPhoto:(UITapGestureRecognizer *)sender
{
    UIImageView *imageView = (UIImageView *)sender.view;
    showImageV.image = imageView.image;
    [self.blackGroundV addSubview:showImageV];
    [UIView animateWithDuration:.5 animations:^{
        showImageV.frame = CGRectMake(0, 0, scrennWidth,screenHeight);
    }];
}
- (void)hiddenImageView:(UITapGestureRecognizer *)sender
{
    [UIView animateWithDuration:.5 animations:^{
        showImageV.frame = CGRectZero;
    }];
}
- (void)deletePhoto:(UISwipeGestureRecognizer*)send
{
    UIAlertView *photoDeleteAlert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"确定要删除这张照片么？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    photoDeleteAlert.tag = 100;
    [photoDeleteAlert show];
    UIImageView *imageView = (UIImageView *)send.view;
    Aphoto = [NSMutableArray arrayWithObject:imageView];
}
- (void)abolishXunjian:(id)sender
{
    [_alertV textFieldAtIndex:0].text = [[Appinfomation shareIstance].loginDic valueForKey:@"user"];
    isAbolished = @"1";
    [_alertV show];
}
- (void)jajajajaj:(UIButton*)btn
{
    UIImage *submitImage = [UIImage imageNamed:@"提交"];
    switch (btn.tag)
    {
        case 0:
        {
            int Count = 0;
            NSDictionary *dicx = @{@"floorId": _floorIdQuanju,@"floorRemark": [_commentTv.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"checkData": _sendCheckDatas};
            NSLog(@" dics == %@",dicx);
            for (int i = 0; i < self.sendFloorDatas.count; i++)
            {
                id str = [self.sendFloorDatas objectAtIndex:i];
                if ([str isKindOfClass:[NSString class]])
                {
                    Count ++;
                }
            }
            if (Count > 0)
            {
                [self.sendFloorDatas replaceObjectAtIndex:[self.floorIds indexOfObjectss: self.floorIdQuanju] withObject:dicx];
                UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"数据保存成功。。。" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [myAlert show];
                [self gotoNextFloor];
                if (Count == 1)
                {
                    [btn setImage:submitImage forState:UIControlStateNormal];
                }
            }
            else
            {
                [_alertV textFieldAtIndex:0].text = [[Appinfomation shareIstance].loginDic valueForKey:@"user"];
                [_alertV show];
            }
        }
            
            break;
        case 1:
        {
            self.navigationController.navigationBar.hidden = YES;
            self.blackGroundV.hidden = NO;
        }
            break;
        case 2:
        {
            self.navigationController.navigationBar.hidden = YES;
            self.blackStopV.hidden = NO;
        }
            break;
            
        default:
            break;
    }
}
#pragma mark - actions
- (void)addNewRightButton
{
    UIImage *image = [UIImage imageNamed:@"对照表"];
    self.rightBarBtn= [UIButton buttonWithType:UIButtonTypeCustom];
    self.rightBarBtn.frame = CGRectMake(60, (44-image.size.height)/2, image.size.width, image.size.height);
    [self.rightBarBtn setBackgroundImage:image forState:UIControlStateNormal];
    [self.rightBarBtn addTarget:self action:@selector(appearCenterView:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* rightBtn = [[UIBarButtonItem alloc]initWithCustomView:self.rightBarBtn];
    self.navigationItem.rightBarButtonItem = rightBtn;
}

- (void)appearCenterView:(UIButton *)send
{
    
}

- (void)hiddenAll
{
    for (UITableView *table in self.tables) {
        table.hidden = YES;
    }
    for (UIButton *btn in _tableBtns) {
        [btn setImage:btnImage1 forState:UIControlStateNormal];
    }
}
- (void)showAlertSuccess
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示：" message:[NSString stringWithFormat:@"%@，数据提交成功了哦。。。",[[Appinfomation shareIstance].loginDic valueForKey:@"username"]] delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    alert.tag = 2008;
    [alert show];
}
- (void)showAlertFail
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    UIAlertView *failAlert = [[UIAlertView alloc]initWithTitle:@"警告" message:@"数据提交失败，请重试！！！" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [failAlert show];
}
-(void)hiddenKeyboard
{
    [[[UIApplication sharedApplication]keyWindow]endEditing:YES];
}
- (void)loginSendData
{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [myFloorArr addObjectsFromArray:self.sendFloorDatas];
    if ([isAbolished isEqualToString:@"1"])
    {
        [myFloorArr removeObject:@""];
    }
    if ([Appinfomation shareIstance].strongXunJianCount == 250)
    {
        self.sendAllDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:myFloorArr,@"floorData",[[Appinfomation shareIstance].loginDic valueForKey:@"id"],@"userId",[_checkArea stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"checkArea",[remarkTv.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"abolishRemark",isAbolished,@"isAbolished", nil];
    }
    else if([Appinfomation shareIstance].strongXunJianCount == 191)
    {
        self.sendAllDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:myFloorArr,@"floorData",[[Appinfomation shareIstance].loginDic valueForKey:@"id"],@"userId",_hostStr,@"host",_softwareStr,@"software",_communicationStr,@"communication",[remarkTv.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"abolishRemark",isAbolished,@"isAbolished", nil];
    }
    else if ([Appinfomation shareIstance].strongXunJianCount == 521)
    {
        self.sendAllDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:myFloorArr,@"floorData",[[Appinfomation shareIstance].loginDic valueForKey:@"id"],@"userId",[_humidity stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"humidity",[_temperature stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"temperature",[_weatherForecast stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"weatherForecast",[remarkTv.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"abolishRemark",isAbolished,@"isAbolished", nil];
    }
    else
    {
        self.sendAllDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:myFloorArr,@"floorData",[[Appinfomation shareIstance].loginDic valueForKey:@"id"],@"userId",[remarkTv.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],@"abolishRemark",isAbolished,@"isAbolished", nil];
    }
    NSLog(@"%@",self.sendAllDic);
    NSString *str1 =[self.sendAllDic JSONRepresentation];
    NSURL *sendUrl = [NSURL URLWithString:self.sendUrl];
    sendRequest = [ASIFormDataRequest requestWithURL:sendUrl];
    sendRequest.delegate = self;
    [sendRequest setDidFinishSelector:@selector(showAlertSuccess)];
    [sendRequest setDidFailSelector:@selector(showAlertFail)];
    [sendRequest setPostValue:str1 forKey:@"data"];
    [sendRequest startAsynchronous];
}

- (void)gotoNextFloor
{    //    对tableView的操作
    
    NSInteger row = [self.floorIds indexOfObjectss:self.floorIdQuanju];
    NSIndexPath *path =[NSIndexPath indexPathForRow:row inSection:0];
    NSIndexPath *path1 = [NSIndexPath indexPathForRow:row + 1 inSection:0];
    XunJianCell *cell =(XunJianCell*)[self.myTableView cellForRowAtIndexPath:path];
    cell.gouView.hidden = NO;
    [self.xunJianCellInfos replaceObjectAtIndex:path.row withObject:@{@"hidden": [NSString stringWithFormat:@"0"],@"floorId":self.floorIdQuanju}];
    [UIView animateWithDuration:.5 animations:^{
        self.backScrollV.contentSize = CGSizeZero;
    }];
    if (path1.row < self.floorIds.count)
    {
        [self.myTableView selectRowAtIndexPath:path1 animated:YES scrollPosition:(UITableViewScrollPositionMiddle)];
        [self showUIWithArray:self.allShowDataArr andFloorId:[self.floorIds objectAtIndex:path1.row]];
    }
}

-(UIImage *)addText:(UIImage *)img text:(NSString *)text1
{
    //get image width and height
    int w = img.size.width;
    int h = img.size.height;
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    //create a graphic context with CGBitmapContextCreate
    CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
    CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);
    CGContextSetRGBFillColor(context, 0.0, 1.0, 1.0, 1);
    char *text = (char *)[text1 cStringUsingEncoding:NSASCIIStringEncoding];
    CGContextSelectFont(context, "Georgia", 30, kCGEncodingMacRoman);
    CGContextSetTextDrawingMode(context, kCGTextFill);
    CGContextSetRGBFillColor(context, 255, 225, 208, 115);
    CGContextShowTextAtPoint(context, w/2-strlen(text)*5, h/2, text, strlen(text));
    //Create image ref from the context
    CGImageRef imageMasked = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    CGColorSpaceRelease(colorSpace);
    return [UIImage imageWithCGImage:imageMasked];
}

#pragma mark - 可调用的添加控件的方法
- (void)addChildInputName:(NSMutableArray *)checkChildren andCheckId:(NSString *)chekId andchildIds:(NSMutableArray *)childIds
{
    NSMutableArray *checkContrls = [NSMutableArray array];
    NSMutableArray *checkResults = [NSMutableArray array];
    for (int i = 0; i<checkChildren.count; i++)
    {
        UILabel *childLabel = [UILabel new];
        NSString *string = [checkChildren objectAtIndex:i];
        childLabel.text = [NSString stringWithFormat:@"%@：",string];
        childLabel.font = [UIFont systemFontOfSize:26];
        CGSize mySize = [childLabel.text sizeWithFont:childLabel.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
        childLabel.frame = CGRectMake((_backScrollV.frame.size.width - 62)/checkChildren.count*i+62, [[_checkNameLbs lastObject]frame].origin.y + [[_checkNameLbs lastObject]frame].size.height + 10, mySize.width, mySize.height);
        [_backScrollV addSubview:childLabel];
        [_childLabels addObject:childLabel];
        
        UITextField *inputTf = [[UITextField alloc]initWithFrame:CGRectMake(childLabel.frame.size.width + childLabel.frame.origin.x, childLabel.frame.origin.y, 100, childLabel.frame.size.height)];
        UIImageView *inputView = [[UIImageView alloc]initWithImage:inputImage];
        
        [inputTf setKeyboardType:UIKeyboardTypeNumberPad];
        
        inputView.frame = inputTf.frame;
        inputView.userInteractionEnabled = YES;
        [_backScrollV addSubview:inputView];
        [_backScrollV addSubview:inputTf];
        inputTf.delegate = self;
        [_imageViews addObject:inputView];
        [checkContrls addObject:inputTf];
        NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"",@"childResult",[childIds objectAtIndex:i],@"childId", nil];
        [checkResults addObject:dic];
    }
    NSDictionary *controlDic = [NSDictionary dictionaryWithObjectsAndKeys:chekId,@"checkId",checkContrls,@"control",childIds,@"childIds",checkResults,@"checkResult", nil];
    [sendControls addObject:controlDic];
    //    sendContrls 包含了所有的checkId
    [checkChildren removeAllObjects];
    
}

- (void)addSingleSelect:(NSArray*)options andResult:(NSString *)receiveString
{
    NSMutableArray *btnArr = [NSMutableArray array];
    for (int j =0; j<options.count; j++)
    {
        UIButton *selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [selectBtn setImage:_roundUnselect forState:UIControlStateNormal];
        if ([[NSString stringWithFormat:@"%d",j] isEqualToString: receiveString])
        {
            [selectBtn setImage:_roundSelect forState:UIControlStateNormal];
        }
        else if(([[receiveString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] isEqualToString:@"无异常"] && j == 0) ||([[receiveString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] isEqualToString:@"异常"] && j == 1))
        {
            [selectBtn setImage:_roundSelect forState:UIControlStateNormal];
        }
//        else if (![receiveString isEqualToString:@"0"]&&![receiveString isEqualToString:@"1"]&&![receiveString isEqualToString:@"2"]&&![receiveString isEqualToString:@"3"])
//        {
//            if (j == 1)
//            {
//                [selectBtn setImage:_roundSelect forState:UIControlStateNormal];
//            }
//        }
        [selectBtn addTarget:self action:@selector(selectOptions:) forControlEvents:UIControlEventTouchUpInside];
        selectBtn.frame = CGRectMake(150 + (_backScrollV.frame.size.width - 150)/options.count*j, [[_controlWillClears lastObject]frame].origin.y  /*+([[_controlWillClears lastObject]frame].size.height + 10)*/, _roundSelect.size.width, _roundSelect.size.height);
        [_backScrollV addSubview:selectBtn];
        [_imageViews addObject:selectBtn];
        [_controlWillClears addObject:selectBtn];
        [btnArr addObject:selectBtn];
        
        UILabel *abnormLb = [UILabel new];
        NSString *abnormStr = [options objectAtIndex:j];
        abnormLb.font = [UIFont systemFontOfSize:26];
        abnormLb.text = abnormStr;
        abnormLb.tag = 1000+ j;
        CGSize mySize = [abnormLb.text sizeWithFont:abnormLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
        abnormLb.frame = CGRectMake(selectBtn.frame.origin.x + selectBtn.frame.size.width, selectBtn.frame.origin.y, mySize.width, mySize.height);
        [_backScrollV addSubview:abnormLb];
        [_childLabels addObject:abnormLb];
        [_controlWillClears addObject:abnormLb];
    }
    [_selectBtnArr addObject:btnArr];
    [_seleBtnData addObject:@""];
}
- (void)addRemarkKuang
{
    UILabel *remarkLb = [UILabel new];
    remarkLb.text = @"备注：";
    remarkLb.font = [UIFont systemFontOfSize:25];
    CGSize mySz = [remarkLb.text sizeWithFont:remarkLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    remarkLb.frame = CGRectMake(100, [[self.controlWillClears lastObject]frame].origin.y + [[self.controlWillClears lastObject]frame].size.height + interval111, mySz.width, mySz.height);
    [self.backScrollV addSubview:remarkLb];
    [self.controlWillClears addObject:remarkLb];
    
    UITextField *tf = [[UITextField alloc]initWithFrame:CGRectMake(190, remarkLb.frame.origin.y, 340, mySz.height)];
    tf.delegate = self;
    tf.background = inputImage;
    [self.backScrollV addSubview:tf];
    [self.controlWillClears addObject:tf];
}
- (void)addCommentKuang:(NSString *)text//备注框
{
    UILabel *remarkLb = [UILabel new];
    remarkLb.text = @"备注：";
    remarkLb.font = [UIFont systemFontOfSize:25];
    CGSize mySz = [remarkLb.text sizeWithFont:remarkLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    remarkLb.frame = CGRectMake(10, [[self.controlWillClears lastObject]frame].origin.y + [[self.controlWillClears lastObject]frame].size.height + interval111, mySz.width, mySz.height);
    [self.backScrollV addSubview:remarkLb];
    [self.controlWillClears addObject:remarkLb];
    
    self.commentTv = [[UITextView alloc]init];
    self.commentTv.backgroundColor = [UIColor clearColor];
    self.commentTv.text = [text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    self.commentTv.delegate = self;
    self.commentTv.font = [UIFont systemFontOfSize:20];
    self.commentTv.frame = CGRectMake(remarkLb.frame.size.width + remarkLb.frame.origin.x, remarkLb.frame.origin.y, self.backScrollV.frame.size.width - remarkLb.frame.size.width - remarkLb.frame.origin.x - interval111, 100);
    UIImageView *remarkIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"框"]];
    remarkIV.frame = self.commentTv.frame;
    [self.backScrollV addSubview:remarkIV];
    [self.backScrollV addSubview:self.commentTv];
    self.backScrollV.contentSize = CGSizeMake(self.backScrollV.frame.size.width, self.commentTv.frame.size.height + self.commentTv.frame.origin.y + interval111);
    [self.controlWillClears addObject:self.commentTv];
    [self.controlWillClears addObject:remarkIV];

    
    _backScrollV.contentSize = CGSizeMake(_backScrollV.frame.size.width, _commentTv.frame.origin.y + _commentTv.frame.size.height + interval111);
}
#pragma mark - buttonDelegate
- (void)sureOrCancelDelegate:(UIButton *)btn tag:(NSInteger)tag
{
    switch (btn.tag)
    {
        case 0:
        {
            if (![pickerView.timeDateStr isEqualToString:@""])
            {
                dealTimeTf.text = pickerView.timeDateStr;
            }
        }
            break;
        default:
            break;
    }
    pickerView.hidden = YES;
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == classTable)
    {
        return classTableFactors.count;
    }
    else if (tableView == buWeiTable)
    {
        return _floorNames.count;
    }
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"myCell";
    if (tableView == self.myTableView) {
        self.mycell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        if (!_mycell) {
            _mycell = [[[NSBundle mainBundle]loadNibNamed:@"XunJianCell" owner:self options:nil] lastObject];
        }
        for (int k = 0; k < self.xunJianCellInfos.count; k ++)
        {
            NSDictionary *dic = [self.xunJianCellInfos objectAtIndex:k];
            if ([[dic valueForKey:@"hidden"]boolValue] == NO)
            {
                if ([self.floorIds indexOfObjectss:[dic valueForKey:@"floorId"]] == indexPath.row) {
                    _mycell.gouView.hidden = NO;

                }
            }
        }
        self.mycell.selectedBackgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"按下"]];
        self.mycell.textLabel.textAlignment = 1;
        self.mycell.backgroundColor = [UIColor clearColor];
        self.mycell.textLabel.textColor = [UIColor whiteColor];
        self.mycell.backgroundView = [[UIImageView alloc]initWithImage:self.leftTableImage];
        self.mycell.textLabel.font = [UIFont systemFontOfSize:35];
        self.mycell.textLabel.backgroundColor = [UIColor clearColor];
        return self.mycell;
        
    }
    else if (tableView == classTable)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        cell.textLabel.text = [classTableFactors objectAtIndex:indexPath.row];
        return cell;
    }
    else if (tableView == buWeiTable)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        cell.textLabel.text = [_floorNames objectAtIndex:indexPath.row];
        return cell;
    }
    else
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (!cell) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        return cell;
    }
    
    return nil;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == _myTableView)
    {
        return _leftTableImage.size.height;
    }
    else
    {
        return 30;
    }
    return 0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self hiddenAll];
    [[[UIApplication sharedApplication]keyWindow]endEditing:YES];
    
}

#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView == _alertV || alertView.tag == 250)
    {
        switch (buttonIndex)
        {
            case 1:
            {
                [[[UIApplication sharedApplication]keyWindow]endEditing:YES];
                [MBProgressHUD showHUDAddedTo:self.view animated:YES];
                if ([alertView textFieldAtIndex:0].text.length == 0) {
                    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告！" message:@"请输入用户名！" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
                    [alert show];
                }else if ([alertView textFieldAtIndex:1].text.length == 0){
                    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告！" message:@"请输入密码！" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
                    [alert show];
                }else{
                    NSURL *loginUrl = [NSURL URLWithString:loginIP];
                    loginRequest = [[ASIFormDataRequest alloc] initWithURL:loginUrl];
                    [loginRequest setPostValue:[NSString stringWithFormat:@"%@",[alertView textFieldAtIndex:0].text] forKey:@"user"];
                    [loginRequest setPostValue:[NSString stringWithFormat:@"%@",[alertView textFieldAtIndex:1].text] forKey:@"password"];
                    [loginRequest startAsynchronous];
                    loginRequest.delegate = self;
                    [loginRequest setDidFinishSelector:@selector(loginSuccess)];
                    [loginRequest setDidFailSelector:@selector(loginFailed)];
                }
            }
                break;
                
            default:
                
                break;
        }
    }
    else if (alertView.tag == 100)
    {
        switch (buttonIndex) {
            case 0:
                break;
            case 1:
            {
                for (UIImageView *imageV in photos)
                {
                    [imageV removeFromSuperview];
                }
                [photos removeObjectsInArray:Aphoto];
                for (int i = 0;i<photos.count;i++)
                {
                    UIImageView *imageV = [photos objectAtIndex:i];
                    imageV.frame = CGRectMake(contentTv.frame.origin.x + (imageV.frame.size.width + interval111)*i, contentTv.frame.origin.y + contentTv.frame.size.height + interval111, imageV.frame.size.width, imageV.frame.size.height);
                    [self.blackGroundV addSubview:imageV];
                }
                if (photos.count)
                {
                    takePhotoBtn.frame = CGRectMake([[photos lastObject]frame].origin.x + [[photos lastObject]frame].size.width + interval111, takePhotoBtn.frame.origin.y, takePhotoBtn.frame.size.width, takePhotoBtn.frame.size.height);
                }
                else
                {
                    takePhotoBtn.frame = CGRectMake(contentTv.frame.origin.x, contentTv.frame.origin.y + contentTv.frame.size.height + interval111, takePhotoBtn.frame.size.width, takePhotoBtn.frame.size.height);
                }
                takePhotoBtn.hidden = NO;
            }
            default:
                break;
        }
        
    }
    else if (alertView.tag == 2008)
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
//    NSLog(@"%d",buttonIndex);
    switch (buttonIndex) {
        case 0:
        {
            if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
                UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
                imagePicker.delegate = self;
                imagePicker.allowsEditing = YES;
                imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
                [self.navigationController presentViewController:imagePicker animated:YES completion:nil];
            }
        }
            break;
        case 1:
        {
            UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
            if ([UIImagePickerController isSourceTypeAvailable:
                 UIImagePickerControllerSourceTypePhotoLibrary]) {
                imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                imagePicker.delegate = self;
                [imagePicker setAllowsEditing:NO];
                UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
                self.popController = popover;
                [self.popController presentPopoverFromRect:takePhotoBtn.frame inView:self.blackGroundV permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
                //[popover release];
                //[imagePicker release];
            } else {
                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"Error accessing photo library!" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
                [alert show];
            }  

        }
            break;
        default:
            break;
    }
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image;
    if (picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary)
    {
        image = [info objectForKey:UIImagePickerControllerOriginalImage] ;
    }
    else
    {
        image = [info objectForKey:UIImagePickerControllerOriginalImage] ;
    }
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
//    NSString *locationString=[formatter stringFromDate: [NSDate date]];
//    NSString *photoInfo = [NSString stringWithFormat:@"拍照时间：%@ 拍照楼层：%@",locationString,_floorIdQuanju];
//    UIImage *photo = [self addText:image text:photoInfo];
    UIImageView *photoView = [[UIImageView alloc]initWithImage:image];
    photoView.frame = takePhotoBtn.frame;
    photoView.userInteractionEnabled = YES;
    UISwipeGestureRecognizer *longTap = [UISwipeGestureRecognizer new];
    [longTap addTarget:self action:@selector(deletePhoto:)];
    [photoView addGestureRecognizer:longTap];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(displayPhoto:)];
    [photoView addGestureRecognizer:tap];
    [self.blackGroundV addSubview:photoView];
    [photos addObject:photoView];
    if (photos.count == 5)
    {
        takePhotoBtn.hidden = YES;
    }
    else
    {
        takePhotoBtn.hidden = NO;
        takePhotoBtn.frame = CGRectMake(takePhotoBtn.frame.origin.x + takePhotoBtn.frame.size.width +interval111, takePhotoBtn.frame.origin.y, takePhotoBtn.frame.size.width, takePhotoBtn.frame.size.height);
    }
        [picker dismissViewControllerAnimated:YES completion:nil];
        [self.popController dismissPopoverAnimated:YES];
}
#pragma mark - UITextViewDelegate
- (void)textViewDidBeginEditing:(UITextView *)textView
{
    [self hiddenAll];
    
    if (textView.frame.origin.y + textView.frame.size.height + _backScrollV.frame.origin.y- _backScrollV.contentOffset.y + 5>= 768 - 456)
    {
        [_backScrollV setContentOffset:CGPointMake(_backScrollV.contentOffset.x, _backScrollV.contentOffset.y - (_backScrollV.frame.size.height - 406 + 10)+(textView.frame.origin.y + 40 - _backScrollV.contentOffset.y)-50) animated:YES];
//        [_backScrollV setContentOffset:CGPointMake(_backScrollV.contentOffset.x, _backScrollV.contentOffset.y - (_backScrollV.frame.size.height - 406 + 10)+(textView.frame.origin.y + textView.frame.size.height - _backScrollV.contentOffset.y)) animated:YES];
    }
}
//- (void)textViewDidEndEditing:(UITextView *)textView
//{
//    self.backScrollV.contentOffset = CGPointMake(self.backScrollV.frame.size.width, textView.frame.origin.y + textView.frame.size.height + interval111);
//}

#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if ([cannotEditTfs containsObject:textField])
    {
        return NO;
    }
    
    return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    [self hiddenAll];
    
    if (textField.frame.origin.y + textField.frame.size.height + _backScrollV.frame.origin.y- _backScrollV.contentOffset.y + 5>= 768 - 456)
    {
        [_backScrollV setContentOffset:CGPointMake(_backScrollV.contentOffset.x, _backScrollV.contentOffset.y - (_backScrollV.frame.size.height - 406 + 10   )+(textField.frame.origin.y + textField.frame.size.height - _backScrollV.contentOffset.y)-120) animated:YES];
    }
    NSLog(@"%f",textField.frame.origin.y + textField.frame.size.height + _backScrollV.frame.origin.y- _backScrollV.contentOffset.y + 5);
    NSLog(@"%f",_backScrollV.contentOffset.y - (_backScrollV.frame.size.height - 406 + 10   )+(textField.frame.origin.y + textField.frame.size.height - _backScrollV.contentOffset.y)-120);
}

#pragma mark - FridUtilDelegate
//- (void)frid:(NSNumber *)number
//{
//    NSLog(@"%lld",number.longLongValue);
//    NSDateFormatter *dateFormatter = [NSDateFormatter new];
//    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//    NSString *fromDateString = [dateFormatter stringFromDate:[NSDate date]];
//    NSString * url = [NSString stringWithFormat:@""];
//    switch ([[[Appinfomation shareIstance].loginDic valueForKey:@"departmentid"]integerValue]) {
//        case 1:
//        {
//            url  = [NSString stringWithFormat:sendGaoQuFrid,[[Appinfomation shareIstance].loginDic valueForKey:@"id"],[[Appinfomation shareIstance].loginDic valueForKey:@"departmentid"],_floorIdQuanju,fromDateString,[NSString stringWithFormat:@"%lld",number.longLongValue]];
//        }
//            break;
//        case 2:
//        {
//            url = [NSString stringWithFormat:sendQiangDianFrid,[[Appinfomation shareIstance].loginDic valueForKey:@"id"],[[Appinfomation shareIstance].loginDic valueForKey:@"departmentid"],_floorIdQuanju,fromDateString,[NSString stringWithFormat:@"%lld",number.longLongValue]];
//        }
//            break;
//        case 3:
//        {
//            url = [NSString stringWithFormat:sendRiChangFrid,[[Appinfomation shareIstance].loginDic valueForKey:@"id"],[[Appinfomation shareIstance].loginDic valueForKey:@"departmentid"],self.floorIdQuanju,fromDateString,[NSString stringWithFormat:@"%lld",number.longLongValue]];
//        }
//            break;
//        default:
//            break;
//    }
//    NSURL *newurl =  [[NSURL alloc] initWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
//    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:newurl];
//    [request setDelegate:self];
//    [request setDidFinishSelector:@selector(requestDonele:)];
//    [request setDidFailSelector:@selector(requestWentWrongle:)];
//    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//    [request startAsynchronous];
//    [MBProgressHUD hideHUDForView:self.view animated:YES];
//}
- (void)reReadData
{
    [self.fridUtil readData];
}
- (void)openRead
{
        [((AppDelegate*)[[UIApplication sharedApplication] delegate]) openReadFrid];
}
//- (void)closeRead
//{
//    [((AppDelegate *)[[UIApplication sharedApplication]delegate ])closeReadFrid];
//}
-(void)doSomething:(NSNotification*)send
{
    NSString *epc =[send object];
    NSLog(@"jgc,,%@",epc);
    NSDateFormatter *dateFormatter = [NSDateFormatter new];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *fromDateString = [dateFormatter stringFromDate:[NSDate date]];
    NSString * url = [NSString stringWithFormat:@""];
    url  = [NSString stringWithFormat:addQianDaoRecord,[[Appinfomation shareIstance].loginDic valueForKey:@"username"],[[Appinfomation shareIstance].loginDic valueForKey:@"departmentid"],_floorIdQuanju,fromDateString,[NSString stringWithFormat:@"%@",epc],_checkXunJianArea];
    //userId=1&departmentId=1&floorId=1&regTime=2014-01-13 16:36:50&rfid=E2002075581900832551413&checkArea=1
    NSURL *newurl =  [[NSURL alloc] initWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:newurl];
    [request setDelegate:self];
    [request setDidFinishSelector:@selector(requestDonele:)];
    [request setDidFailSelector:@selector(requestWentWrongle:)];
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [request startAsynchronous];
    //    [[NSNotificationCenter  defaultCenter]removeObserver:self name:@"frid" object:nil];
//    [self closeRead];
    [NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(reReadData) userInfo:nil repeats:NO];
//    [NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(openRead) userInfo:nil repeats:NO];

}

#pragma mark - ASIHttpDelegate
- (void)requestDonele:(ASIHTTPRequest *)request
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    myAlertView.hidden = NO;
    NSString *response = [request responseString];
    NSDictionary *queryDic = [response JSONValue];
    NSDictionary *queryDataArr = [queryDic objectForKey:@"data"];
    NSLog(@"查询%@",queryDataArr);
    if (queryDataArr)
    {
        NSString *newFloorId = [NSString stringWithFormat:@"%@",[queryDataArr objectForKey:@"id"]];
        NSInteger index = [self.floorIds indexOfObject:newFloorId];
        NSIndexPath *path =[NSIndexPath indexPathForRow:index inSection:0];
        [self.myTableView selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionMiddle];
        [self tableView:self.myTableView didSelectRowAtIndexPath:path];
        [UIView animateWithDuration:.2 animations:^{
            myAlertView.frame = CGRectMake(0, 0, scrennWidth, screenHeight);
        }];
    }
    else
    {
        UIAlertView *aler = [[UIAlertView alloc]initWithTitle:@"警告！" message:@"无法识别！" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [aler show];
    }
}
- (void)requestWentWrongle:(id)sender
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"签到失败！请重新读取！" delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
    [alertView show];
}
- (void)loginSuccess
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    NSString *response = [loginRequest responseString];
    NSDictionary *responseDic = [response JSONValue];
    NSDictionary *DataDic = [responseDic objectForKey:@"data"];
    if (DataDic == nil) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告！" message:@"网络无法连接！" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
        [alert show];
    }else if ([DataDic isEqual:[NSString stringWithFormat:@"NONE"]]) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告！" message:@"用户名不存在！" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
        [alert show];
    }else if ([DataDic isEqual:[NSString stringWithFormat:@"FAILURE"]]){
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"警告！" message:@"用户密码错误！" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
        [alert show];
    }
    else
    {
        [self loginSendData];
    }
}
- (void)loginFailed
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    UIAlertView *failAlert = [[UIAlertView alloc]initWithTitle:@"警告！！" message:@"登录失败" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [failAlert show];
}

#pragma mark - keyboardNotification
CGSize keyboardSize;
- (void) keyboardWasShown:(NSNotification *) notif
{
    NSDictionary *info = [notif userInfo];
    NSValue *value = [info objectForKey:UIKeyboardFrameBeginUserInfoKey];
    keyboardSize = [value CGRectValue].size;
    NSLog(@"keyBoard:%f", keyboardSize.width);  //216
    _backScrollV.contentSize = CGSizeMake(_backScrollV.frame.size.width, _commentTv.frame.origin.y + _commentTv.frame.size.height + interval111+406);
    if (self.blackGroundV.hidden == NO)
    {
        [UIView animateWithDuration:.5 animations:^{
            self.blackGroundV.frame = CGRectMake(0, -150, 1024, 768);
        }];
    }
    if (self.blackStopV.hidden == NO) {
        [UIView animateWithDuration:.5 animations:^{
            self.blackStopV.frame = CGRectMake(0, -150, 1024, 768);
        }];
    }
}
- (void) keyboardWasHidden:(NSNotification *) notif
{
    NSDictionary *info = [notif userInfo];
    NSValue *value = [info objectForKey:UIKeyboardFrameBeginUserInfoKey];
    CGSize keyboardSize = [value CGRectValue].size;
    NSLog(@"keyboardWasHidden keyBoard:%f", keyboardSize.width);
    _backScrollV.contentSize = CGSizeMake(_backScrollV.frame.size.width, _commentTv.frame.origin.y + _commentTv.frame.size.height + interval111);
    if (self.blackGroundV.hidden == NO)
    {
        [UIView animateWithDuration:0.5 animations:^{
            self.blackGroundV.frame = CGRectMake(0, 0, 1024, 768);
        }];
    }
    if (self.blackStopV.hidden == NO) {
        [UIView animateWithDuration:.5 animations:^{
            self.blackStopV.frame = CGRectMake(0, 0, 1024, 768);
        }];
    }
}
#pragma mark - end
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
